package com.etc.user.controller;/*
 * 文件名：com.etc.user.controller
 * 描述：
 * 作者：蒋丽娟
 * 时间：2019/5/26 13:10
 */

import com.etc.entity.Goods;
import com.etc.entity.GoodsPicture;
import com.etc.entity.OneLevel;
import com.etc.entity.TwoLevel;
import com.etc.service.GoodsPictureService;
import com.etc.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
@RequestMapping("user.action")
public class IntroductionController {
    @Autowired
    private GoodsService goodsService;
    @Autowired
    private GoodsPictureService goodsPictureService;
    @RequestMapping("tointroduction")
    public ModelAndView introduction(Integer goodsid){
        ModelAndView mv=new ModelAndView("user/introduction");
        Goods goods=goodsService.selectByPrimaryKey(goodsid);
        //得到商品对应的商品信息
        List<GoodsPicture> list=goodsPictureService.listGoodspictureByGid(goodsid);
        //通过商品的id得到该商品的带首页图片的信息
       GoodsPicture goodsPicture=goodsPictureService.getGoodspictureByGid(goodsid);

        //传递整个goods对象
        mv.addObject("goods",goods);
        //传递该商品的图片信息
        mv.addObject("list",list);
        //传递该商品的首页图片信息
        mv.addObject("goodsPicture",goodsPicture);
        return mv;
    }
}
